<?php
declare (strict_types = 1);
namespace app\model\tablenot\tool;

use app\model\table\config\ConfigGlobal;
use app\model\tablenot\TablenotBaseModel;

// 获取坐标地址
class LonLatAddress extends TablenotBaseModel {
    protected $lon;
    protected $lat;

    public function __construct($lon, $lat)
    {
        $this->lon = $lon;
        $this->lat = $lat;
    }

    public function get()
    {
        if($this->lon == "0" || $this->lat == "0"){
            return "未知";
        }
        $urlModel = ConfigGlobal::instance()->findValue("lon_lat_address");
        $urlModel = str_ireplace('{param1}', $this->lon, $urlModel);
        $urlModel = str_ireplace('{param2}', $this->lat, $urlModel);
        $rs = Tool::getCurl($urlModel);
        if($rs['code'] == 200){
           return $rs['data'];
        }else{
           return "未知";
        }
    }
}